package com.zx.kitchen.index.common.mvp.presenter;

import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.zx.kitchen.index.common.entity.ReportIndexPictureBean;
import com.zx.kitchen.index.common.mvp.OnResultListener;
import com.zx.kitchen.index.common.mvp.model.BusinessReportIndexPicModelImpl;
import com.zx.kitchen.index.common.mvp.view.BusinessReportIndexPicView;

/**
 * Created by Administrator on 2017/3/17.
 */

public class BusinessReportIndexPicPresenter implements OnResultListener {
    private BusinessReportIndexPicModelImpl businessReportIndexPicModel;
    private BusinessReportIndexPicView businessReportIndexPicView;
    private Context context;

    public BusinessReportIndexPicPresenter(BusinessReportIndexPicView businessReportIndexPicView, Context context) {
        this.businessReportIndexPicView = businessReportIndexPicView;
        this.context = context;
        businessReportIndexPicModel = new BusinessReportIndexPicModelImpl();
    }

    public void getDataFromNet(String type ,String start_time,String end_time){
        businessReportIndexPicModel.getFromNet(1,context,type,start_time,end_time,this,null);
    }


    @Override
    public void onSuccess(int requestCode, String str) {
        ReportIndexPictureBean reportIndexPictureBean = JSON.parseObject(str, new TypeReference<ReportIndexPictureBean>() {
        });
        businessReportIndexPicView.onSuccess(reportIndexPictureBean);

    }

    @Override
    public void onFailure(int requestCode, String str) {
        businessReportIndexPicView.onFail(str);
    }
}
